import java.util.*;

public class Gloves {
    public int findMinimum(int n, int[] left, int[] right) {
        // write code here
        int leftmin = Integer.MAX_VALUE;
        int rightmin = Integer.MAX_VALUE;
        int leftsum = 0;
        int rightsum = 0;
        int ret = 0;
        for(int i = 0;i<left.length;i++) {
            if(0 == left[i] || 0 == right[i]) {
                ret+=left[i]+right[i];
            }else {
                leftmin = Math.min(left[i],leftmin);
                rightmin = Math.min(right[i],rightmin);
                leftsum+=left[i];
                rightsum+=right[i];
            }
           
        }
        leftsum+=ret;
        rightsum+=ret;
        return Math.min(leftsum-leftmin,rightsum-rightmin)+2;
    }
}